package com.njupt.simulation.service.Impl;

import com.njupt.simulation.entity.Link;
import com.njupt.simulation.entity.Scenario;
import com.njupt.simulation.entity.Station;
import com.njupt.simulation.service.ProcessScenarioService;

import java.time.LocalDateTime;

public class ProcessScenarioServiceImpl implements ProcessScenarioService {
    @Override
    public void processScenario(Scenario scenario, LocalDateTime time) {
        for (Link link : scenario.getLinks()) {//循环场景中的每一条链路
            if (link.getTransmitter() instanceof Station) {//用来判断发射端是什么类型,instanceof用于判断一个对象是否是特定类的实例，这里判断链路的发射端是否是地球站
                Station station = (Station) link.getTransmitter();//如果是地球站，这个节点转换为 Station 类型
                double diameter = station.getDiameter();//通过get()方法拿到节点的数据
                System.out.println("Frequency: " + diameter);
            }
        }
    }
}
